<?php

namespace App\Http\Livewire\Common;

use App\Models\Archive;
use Livewire\Component;

class Preview extends Component
{
    public $visible = false;
    public $archive;
    public $files = [];

    public $listeners = ['showPreview'];
    public function showPreview($id, $index, $url)
    {
        $this->archive = Archive::with('files')->find($id);
        $this->index = $index;
        $this->url = $url;
        $this->files = $this->archive->files;
        $this->emit('setPreviewData', $this->files);
    }
    public function render()
    {
        return view('livewire.common.preview');
    }
}
